//
//  InviteReexamineSelectJobViewController.m
//  Btpin
//
//  Created by Vic on 2019/4/21.
//  Copyright © 2019 Vic. All rights reserved.
//

#import "InviteReexamineSelectJobViewController.h"
#import "SelectJobCell.h"

@interface InviteReexamineSelectJobViewController ()<UITableViewDelegate, UITableViewDataSource>
{
    UITableView *jobTableView;
}
@end

@implementation InviteReexamineSelectJobViewController

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    [self.navigationController setNavigationBarHidden:NO animated:YES];
}
- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self initUI];
}
- (void)okBtnTap {
    if (self.dataArray.count) {
        for (CompanyJobModel *model in self.dataArray) {
            if (model.isSelect) {
                self.select(model.id, model.title, model.wage_cn);
                break;
            }
        }
    }
    [self.navigationController popViewControllerAnimated:YES];
}
- (void)initUI {
    self.navigationItem.title = @"选择我发布的职位";
    
    UIButton *okBtn = [UIToolsControl initButtonWithFrame:CGRectMake(0, 0, 60*Scale, 44) imageName:nil target:self action:@selector(okBtnTap) title:@"确定" titleColor:THEMECOLOR_OF_ORANGE];
    okBtn.titleLabel.font = Font(Font_15);
    UIBarButtonItem *rightItem = [[UIBarButtonItem alloc] initWithCustomView:okBtn];
    self.navigationItem.rightBarButtonItem = rightItem;
    
    jobTableView = [UIToolsControl initTableViewWithFrame:CGRectMake(0, 0, WIDTH, HEIGHT-HeightOfStatusBarAndNavigationBar-SIMEmojKeyBoardkBottomNOSafeArea_Height) target:self style:UITableViewStylePlain];
    jobTableView.tableFooterView = [[UIView alloc] init];
    jobTableView.rowHeight = 50*Scale;
    [self.view addSubview:jobTableView];
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    if (self.dataArray.count) {
        return self.dataArray.count;
    }
    return 0;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    SelectJobCell *cell = [tableView dequeueReusableCellWithIdentifier:isCellID];
    if (!cell) {
        cell = [[SelectJobCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:isCellID];
    }
    InterviewBaseinfoJobModel *model = self.dataArray[indexPath.row];
    [cell reloadDataForModelIM:model];
    
    return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    for (NSInteger i = 0; i<self.dataArray.count; i++) {
        InterviewBaseinfoJobModel *model = self.dataArray[i];
        if (i == indexPath.row) {
            model.isSelect = YES;
        } else {
            model.isSelect = NO;
        }
    }
    [tableView reloadData];
}

@end
